﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dominio;
using FluentNHibernate.Mapping;

namespace Infra.NHibernateFramework {
    public class ContratoMap : ClassMap<Contrato>{
        public ContratoMap() {
            Id(x => x.Id, "IdContrato");

            Map(x => x.QtdParcelas)
                .Not.Nullable();
            Map(x => x.Inicio)
                .Not.Nullable();
            Map(x => x.Final)
                .Not.Nullable();
            Map(x => x.Valor)
                .Not.Nullable();
            Map(x => x.Tipo, "TipoContrato")
                .Not.Nullable()
                .CustomType<TipoContrato>();

            HasMany(x => x.Lancamentos)
                .KeyColumn("IdContrato")
                .Not.KeyUpdate()
                .Cascade.AllDeleteOrphan()
                .LazyLoad()
                .AsBag();
        }
    }
}

/*
        public virtual IList<Lancamento> Lancamentos { get; set; }
 */
